﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace AttributesExercise
{
    class AttributesExerciseProgram
    {
       
        static void Main(string[] args)
        {
            Type type = typeof(VersionsInAction);
            MethodInfo[] methods = type.GetMethods(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static);
            Dictionary<string, MethodInfo> versions = new Dictionary<string, MethodInfo>();

            foreach (MethodInfo method in methods)
            {
                VersionAttribute attribute = Attribute.GetCustomAttribute(method, typeof(VersionAttribute), false)
                    as VersionAttribute;

                if (attribute == null)
                {
                    continue;
                }

                versions.Add(attribute.Version + " " + attribute.Comment, method);
            }

            foreach (string key in versions.Keys)
            {
                Console.WriteLine(versions[key].Name + "-" + key);
            }

        }
    }
}
